package 剑指offer.Month7_07.day17;

public class 构建乘积数组 {
    public int[] multiply(int[] A) {
        int[] B = new int[A.length];
        B[0] = 1;
        for (int i = 1; i < A.length; i++) {
            B[i] = B[i - 1] * A[i - 1];
        }
        int tmp = 1;
        for (int i = B.length - 1; i >= 0;i--) {
            B[i] *= tmp;
            tmp *= A[i];
        }
        return B;
    }
}
